$(function() {
    $('#showbasicmemberbenefits').click(showbasicmemberbenefits);
    $('#basicmemberbenefits').css({border: '2px solid #E3E3E3',
                                   padding: '10px'
                                   });
    $('#duesTable .select').click(showDuesForm);
});

function showbasicmemberbenefits() {
    var trigger=$(this);
    var target=$('#basicmemberbenefits');
    if (target.css('display')=='none') {
        trigger.html('FDCA Membership Benefits (close)');
        target.fadeIn();
    } else {
        trigger.html('FDCA Membership Benefits (open)');
        target.fadeOut();
    }
}

function showDuesForm() {
    var select=$(this);
    var tier=select.attr('id').split('-')[1];
    var formCol=$('#tier-' + tier + '-form');
    var payCol=$('#tier-' + tier + '-pay');
    var tierRow=$('#tier-' + tier);
    $('.maintr').hover(function(){$(this).css('background','#AAFFFF').css('transition','background 0.2s');}, function(){$(this).css('background','#FFF').css('transition','background 0.2s');});
    if (formCol.css('display')=='table-cell') {
        select.html('Select');
        $('#aadr-' + tier + ', #total-' + tier).css('font-weight','normal');
        formCol.fadeOut();
        payCol.fadeOut();
        tierRow.css('background','#FFF').css('transition','background 0.2s');
        return;
    }
    var payVals, full, month;
    full=$('#tier-' + tier + ' .full').text();
    month=$('#tier-' + tier + ' .month').text();
    
    $('#duesTable span').css('font-weight','normal');
    $('.maintr').css('background','#FFF').css('transition','background 0.2s');
    $('.tierForm, .tierPay').fadeOut().empty();
    $('.select').html('Select');
    select.html('Close');
    tierRow.css('background','#AAFFFF').css('transition','background 0.2s')
        .hover(function(){$(this).css('background','#AAFFFF');}, function(){$(this).css('background','#AAFFFF');});
    $('#aadr-' + tier + ', #total-' + tier).css('font-weight','bold');
    formCol.html('<b>STEP 1: Please Complete and Submit This Form:</b><br/><iframe id="infoForm" src="https://docs.google.com/a/fl-dc.org/forms/d/1bBnEnb1Vmks5PqgxaazT3qBm6PuH_mjUyiMnD4TrYuk/viewform?embedded=true" width="100%" height="450" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>').fadeIn();
    payCol.html('<b>STEP 2: Please Select Your Method of Payment:</b><br/><br/><div style="display: inline-block;"><form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"><input type="hidden" name="cmd" value="_s-xclick"><input name="hosted_button_id" type="hidden" value="ND5XMDG7YRD8W" /><table style="display:none;"><tr><td><input type="hidden" name="on0" value="Dues Based on Average Annual Florida Defense Revenue">Dues Based on Average Annual Florida Defense Revenue</td></tr><tr><td><select name="os0" id="duesSelectAnnual"><option value="over $20M -">over $20M - $2,000.00 USD</option><option value="$10M to $20M -">$10M to $20M - $1,000.00 USD</option><option value="$5M to $10M -">$5M to $10M - $500.00 USD</option><option value="$2.5M to $5M -">$2.5M to $5M - $250.00 USD</option><option value="up to $2.5M -">up to $2.5M - $175.00 USD</option></select> </td></tr></table><input class="paySubmitBtn" name="submit" type="submit" value="Pay Dues ' + full + ' Online" /></form><img alt="" border="0" src="https://lh6.googleusercontent.com/-P93XdkBy5_U/UIb6ZmWRoAI/AAAAAAAAAao/PRTWF2kFJ6E/s1280/creditcards-logos.jpg" style="width:155px;visibility:hidden;" /></div><div style="display: inline-block;"><form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"><input type="hidden" name="cmd" value="_s-xclick"><input name="hosted_button_id" type="hidden" value="7FLJUUPYVT6YQ" /><table style="display:none;"><tr><td><input type="hidden" name="on0" value="Dues Based on Average Annual Florida Defense Revenue">Dues Based on Average Annual Florida Defense Revenue</td></tr><tr><td><select name="os0" id="duesSelectMonthly"><option value="over $20M">over $20M : $166.67 USD - monthly</option><option value="$10M to $20M">$10M to $20M : $83.34 USD - monthly</option><option value="$5M to $10M">$5M to $10M : $41.67 USD - monthly</option><option value="$2.5M to $5M">$2.5M to $5M : $20.84 USD - monthly</option><option value="up to $2.5M">up to $2.5M : $14.59 USD - monthly</option></select> </td></tr></table><input class="paySubmitBtn" name="submit" type="submit" value="Pay Dues ' + month + ' Online" /></form><img alt="" border="0" src="https://lh6.googleusercontent.com/-P93XdkBy5_U/UIb6ZmWRoAI/AAAAAAAAAao/PRTWF2kFJ6E/s1280/creditcards-logos.jpg" style="width:155px;visibility:hidden;" /></div><div style="display:inline-block;text-align:left;margin-bottom:40px;">PayPal is our online merchant service. You do not need a PayPal account.<br/>PayPal accepts American Express, Visa, MasterCard, and Discover.</div><div style="margin-bottom:40px;"><a class="paySubmitBtn invoice" href="mailto:contact@fl-dc.org?subject=Requesting an FDCA Membership Invoice for - YOUR COMPANY NAME&body=Requesting an FDCA Membership Invoice in the amount of ' + full.replace(' in full','') + '" target="_blank">Request Invoice ' + full + ' to pay via Check/Mail</a></div>').fadeIn();
    $('.paySubmitBtn').closest('div').hover(function() { $(this).find('img').css('visibility','visible'); }, function() { $(this).find('img').css('visibility','hidden'); } );
    setTimeout(function() {
        $('html, body').animate({
        scrollTop: tierRow.offset().top
        }, 400);
    },800);
    $('#duesSelectAnnual option')[tier-1].selected=true;
    $('#duesSelectMonthly option')[tier-1].selected=true;
}